﻿using System;
using System.Drawing;
using System.Collections.Generic;
using System.Text;
using DirectUI.Mobile.UI.Drawing.GdiPlus;
using DirectUI.Mobile.UI.Drawing;

namespace DirectUI.Mobile.UI.Controls
{
  public   class DirectUIMenu:DirectUIPanel
    {
      public DirectUIMenu()
      {
          this.Bounds = new System.Drawing.Rectangle(10, 100, 220, 100);
          this.BackColor = Color.White;
      }
      protected override void OnPaintBackground(DirectUIPaintEventArgs e)
      {
          if (BackGroundImage != null)
          {
              Rectangle desRec = e.ControlBounds;
              if (invalidRegion != null)
              {
                  RectangleF recF = invalidRegion.GetBounds(e.Graphics);
                  desRec = new Rectangle((int)recF.X, (int)recF.Y, (int)recF.Width, (int)recF.Height);
              }
              e.Graphics.DrawImage(BackGroundImage, desRec, this.ClientRectangle, GraphicsUnit.Pixel);
          }
          else
          {
              if (GradientFill)
              {
                  this.PaintGradientBackground(e, 50, GradientFillOffset > 0 ? GradientFillOffset : Height);
              }
              else
              {
                  Graphics g = e.Graphics;
                  using (GraphicsPlus gp = new GraphicsPlus(g))
                  {
                      GraphicsPlus.GradientMode mode = IsDown ? GraphicsPlus.GradientMode.Bottom : GraphicsPlus.GradientMode.Top;
                      gp.GradientFillShape(this.Bounds, 30, this.BackColor, this.BackColor, GraphicsPlus.GradientMode.Top, GraphicShape.Rounded, RoundedCorners.Top);
                      using (PenPlus pen = new PenPlus(this.BackColor, (float)1))
                      {
                          gp.DrawShape(this.Bounds, 30, pen, GraphicShape.Rounded, RoundedCorners.Top);
                      }
                  }
              }
          }
          //if (IsOpaque || HasCustomPaintBackgound) base.OnPaintBackground(e);
          //else
          //{
          //    CreateTransparentBGColor();
          //    using (GraphicsPlus gp = new GraphicsPlus(e.Graphics))
          //    {
          //        using (SolidBrushPlus brush = new SolidBrushPlus(transparentBgColor))
          //        {
          //            gp.FillRectangle(brush, e.ControlBounds);
          //        }
          //    }
          //}
      }

    }
}
